#include <string.h>
#include <stdlib.h>

#define WIDTH         16
#define HEIGHT       8
#define CELL_X        8
#define CELL_Y        1

typedef enum ELEMENT {
	AIR,
	BLOCK,
	MOVING
}ELEMENT;

typedef enum SHAPE_TYPE {
	O_SHAPE=0, J_SHAPE, L_SHAPE, T_SHAPE, I_SHAPE, S_SHAPE, Z_SHAPE, MAX_SHAPE
}SHAPE_TYPE;

typedef struct COORD {
    char X;
    char Y;
}COORD;

COORD faller[4];
COORD next_faller[4];
SHAPE_TYPE now_shape;

//不可修改
char code shapes[MAX_SHAPE][8] = {
	{4,3,5,3,4,4,5,4},
	{4,4,5,4,6,4,4,3},
	{5,4,4,4,3,4,5,3},
	{5,4,4,4,6,4,5,3},
	{4,4,5,4,3,4,6,4},
	{4,3,5,3,4,2,5,4},
	{4,3,5,3,5,2,4,4}
};

char map[HEIGHT][WIDTH]= {0};


short rand(void) {
    static short seed = 12345; // 初始种子值
    seed = (seed * 1103515245 + 12345) % 32768; // 生成新的种子值
    return seed;
}

void generate() {
	char i;
    now_shape = (SHAPE_TYPE)(rand() % MAX_SHAPE);
	memcpy(faller, shapes + now_shape, sizeof(faller));
	for (i = 0; i < 4; i++)
	{
		map[faller[i].Y][faller[i].X] = MOVING;
	}
    
}

void printc(u8 x,u8 y,char c){
    OLED_ShowChar(x*CELL_X,y*CELL_Y,c,8);
}